package com.example.demo.user.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.util.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.example.demo.user.service.IUCommentAppealService;
import com.example.demo.user.entity.UCommentAppeal;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 运营人员评论申诉表 前端控制器
 * </p>
 *
 * @author tao
 * @since 2025-02-11
 */
@RestController
@RequestMapping("/uCommentAppeal")
    public class UCommentAppealController {

    @Autowired
    private IUCommentAppealService uCommentAppealService;

    /**
    * 获取相关列表
     * @param current
     * @param size
     * @return
    */
    @GetMapping("/getUCommentAppealList")
    public Result<?> getUCommentAppealList(@RequestParam(value = "current", required = false, defaultValue = "1")Integer current,
                                            @RequestParam(value = "size", required = false, defaultValue = "10")Integer size,
                                            UCommentAppeal uCommentAppeal){

        Page<UCommentAppeal> page = new Page<>(current,size);
        QueryWrapper<UCommentAppeal> queryWrapper=new QueryWrapper<>(uCommentAppeal);
        queryWrapper.orderByDesc("id");
        return Result.ok(uCommentAppealService.page(page,queryWrapper));
    }

    /**
         * 根据ID查询信息
         */
    @GetMapping("/getUCommentAppealById")
    public Result<?> getUCommentAppealById(Integer id){
        return Result.ok(uCommentAppealService.getById(id));
    }

    /**
         * 修改
         */
    @PutMapping("/updateUCommentAppeal")
    @Transactional
    public Result<?> updateUCommentAppeal(@RequestBody UCommentAppeal uCommentAppeal){
        return Result.ok(uCommentAppealService.updateById(uCommentAppeal));
    }

    /**
         * 新增
         */
    @PostMapping("/addUCommentAppeal")
    public Result<?> addUCommentAppeal(@RequestBody UCommentAppeal uCommentAppeal){
        return Result.ok(uCommentAppealService.save(uCommentAppeal));
    }

    /**
         * 删除
         */
    @DeleteMapping("/deleteUCommentAppealById")
    @Transactional
    public Result<?> deleteUCommentAppeal(Integer id){
        return Result.ok(uCommentAppealService.removeById(id));
    }


}

